package utils;

import android.os.Looper;

import java.util.concurrent.Callable;

import okhttp3.Request;

import static others.Const.SUCCESS;
import static others.Tools.ToastShow;

public class RequestUtil{

    public static void SendRequest(Request request) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    OkhttpUtil.SendRequestWithPost(
                            request,
                            new OkHttpCallback() {
                                @Override
                                public void onFinish(String status, String responseData) {
                                    if (status.equals(SUCCESS)) {

                                    } else {
                                        Looper.prepare();
                                        ToastShow("连接服务器失败,请稍后再试");
                                        Looper.loop();
                                    }
                                }
                            });
                } catch (Exception e) {
                    ToastShow("抱歉了亲,我们可能遇到了些麻烦");
                    e.printStackTrace();
                }
            }
        }).run();
    }
}
